package com.ds.lens.data.service.dao.sql.provider;

import com.ds.lens.data.service.dao.entity.LensMonitorDefine;
import org.apache.ibatis.jdbc.SQL;

public class LensMonitorDefineSqlProvider {

    public String insertSelective(LensMonitorDefine record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("lens_monitor_define");

        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=BIGINT}");
        }

        if (record.getOperator() != null) {
            sql.VALUES("operator", "#{operator,jdbcType=TINYINT}");
        }

        if (record.getThresholdType() != null) {
            sql.VALUES("threshold_type", "#{thresholdType,jdbcType=INTEGER}");
        }

        if (record.getThresholdNumber() != null) {
            sql.VALUES("threshold_number", "#{thresholdNumber,jdbcType=INTEGER}");
        }

        if (record.getWindowType() != null) {
            sql.VALUES("window_type", "#{windowType,jdbcType=TINYINT}");
        }

        if (record.getWindowTime() != null) {
            sql.VALUES("window_time", "#{windowTime,jdbcType=INTEGER}");
        }

        if (record.getDuring() != null) {
            sql.VALUES("during", "#{during,jdbcType=INTEGER}");
        }

        if (record.getThresholdLevel() != null) {
            sql.VALUES("threshold_level", "#{thresholdLevel,jdbcType=VARCHAR}");
        }

        if (record.getNotifyDataMissing() != null) {
            sql.VALUES("notify_data_missing", "#{notifyDataMissing,jdbcType=BIT}");
        }

        if (record.getDelayTime() != null) {
            sql.VALUES("delay_time", "#{delayTime,jdbcType=INTEGER}");
        }

        if (record.getMonitorId() != null) {
            sql.VALUES("monitor_id", "#{monitorId,jdbcType=BIGINT}");
        }

        if (record.getScope() != null) {
            sql.VALUES("scope", "#{scope,jdbcType=VARCHAR}");
        }

        if (record.getMetricName() != null) {
            sql.VALUES("metric_name", "#{metricName,jdbcType=VARCHAR}");
        }

        if (record.getMetricFilter() != null) {
            sql.VALUES("metric_filter", "#{metricFilter,jdbcType=VARCHAR}");
        }

        if (record.getMetricAggr() != null) {
            sql.VALUES("metric_aggr", "#{metricAggr,jdbcType=TINYINT}");
        }

        if (record.getMetricBy() != null) {
            sql.VALUES("metric_by", "#{metricBy,jdbcType=VARCHAR}");
        }

        return sql.toString();
    }

    public String updateByPrimaryKeySelective(LensMonitorDefine record) {
        SQL sql = new SQL();
        sql.UPDATE("lens_monitor_define");

        if (record.getOperator() != null) {
            sql.SET("operator = #{operator,jdbcType=TINYINT}");
        }

        if (record.getThresholdType() != null) {
            sql.SET("threshold_type = #{thresholdType,jdbcType=INTEGER}");
        }

        if (record.getThresholdNumber() != null) {
            sql.SET("threshold_number = #{thresholdNumber,jdbcType=INTEGER}");
        }

        if (record.getWindowType() != null) {
            sql.SET("window_type = #{windowType,jdbcType=TINYINT}");
        }

        if (record.getWindowTime() != null) {
            sql.SET("window_time = #{windowTime,jdbcType=INTEGER}");
        }

        if (record.getDuring() != null) {
            sql.SET("during = #{during,jdbcType=INTEGER}");
        }

        if (record.getThresholdLevel() != null) {
            sql.SET("threshold_level = #{thresholdLevel,jdbcType=VARCHAR}");
        }

        if (record.getNotifyDataMissing() != null) {
            sql.SET("notify_data_missing = #{notifyDataMissing,jdbcType=BIT}");
        }

        if (record.getDelayTime() != null) {
            sql.SET("delay_time = #{delayTime,jdbcType=INTEGER}");
        }

        if (record.getMonitorId() != null) {
            sql.SET("monitor_id = #{monitorId,jdbcType=BIGINT}");
        }

        if (record.getScope() != null) {
            sql.SET("scope = #{scope,jdbcType=VARCHAR}");
        }

        if (record.getMetricName() != null) {
            sql.SET("metric_name = #{metricName,jdbcType=VARCHAR}");
        }

        if (record.getMetricFilter() != null) {
            sql.SET("metric_filter = #{metricFilter,jdbcType=VARCHAR}");
        }

        if (record.getMetricAggr() != null) {
            sql.SET("metric_aggr = #{metricAggr,jdbcType=TINYINT}");
        }

        if (record.getMetricBy() != null) {
            sql.SET("metric_by = #{metricBy,jdbcType=VARCHAR}");
        }

        sql.WHERE("id = #{id,jdbcType=BIGINT}");

        return sql.toString();
    }
}
